//////////////////////////////////////////////////////////////////////////////////////////////////
//																								//
//	edit by Ricale Verst																		//
//																								//
//		base ; Introduction 3D GAME Programming with DirectX 9.0 (Frank D Luna) camera class	//
//																								//
//////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef __Camera_H__
#define __Camera_H__

#include "d3dUtility.h"

class Camera
{
public:
	enum SPEED { SPD_VERYFAST = 30, SPD_FAST = 15, SPD_NORMAL = 3, SPD_SLOW = 1 };
	enum ACCURACY { ACC_GOOD = 1, ACC_NORMAL = 60, ACC_BAD = 200 };

public:
	Camera(const float fDist, const float fSpeed, const D3DXMATRIX* pmatTarget);
	~Camera();

	void   walk(const float dist) { m_vPos +=  m_vLook * dist * m_fSpeed; }
	void strafe(const float dist) { m_vPos += m_vRight * dist * m_fSpeed; }
	void    fly(const float dist) { m_vPos +=    m_vUp * dist * m_fSpeed; }

	bool   gotoTarget(const float delta, const float dist, float fSpeed = 0.0f);
	bool turntoTarget(const float angle);

	void pitch(const float angle);
	void   yaw(const float angle);
	void  roll(const float angle);
	
	void FTpitch(const float angle); // FT;FixedTarget
	void FTyaw(const float angle); // FT;FixedTarget

	void getViewMatrix(D3DXMATRIX* V);
	
	void getPosition(D3DXVECTOR3* pvPos)       { *pvPos = m_vPos + m_vTargetPos; }
	void setPosition(const D3DXVECTOR3* pvPos) { m_vPos = (*pvPos) - m_vTargetPos; }

	void getTarget(D3DXVECTOR3* pvTargetPos) {   *pvTargetPos = m_vTargetPos; }
	void setTarget(const D3DXMATRIX* pmatTarget);
	
	void getRight(D3DXVECTOR3* pvRight) { *pvRight = m_vRight; }
	void    getUp(D3DXVECTOR3* pvUp)    {    *pvUp = m_vUp; }
	void  getLook(D3DXVECTOR3* pvLook)  {  *pvLook = m_vLook; }

	float getSpeed() { return m_fSpeed; }

private:
	D3DXVECTOR3 m_vRight;
	D3DXVECTOR3 m_vUp;
	D3DXVECTOR3 m_vLook;
	D3DXVECTOR3 m_vPos;

	D3DXVECTOR3 m_vTargetUp;
	D3DXVECTOR3 m_vTargetLook;
	D3DXVECTOR3 m_vTargetPos;

	float m_fSpeed;
};

#endif // __Camera_H__